package routers

import (
	"myRbac/controllers/userController"
	"myRbac/controllers/userRoleController"
	middleware "myRbac/middlewares"

	"github.com/gin-gonic/gin"
)

func UserApi(r *gin.RouterGroup) {
	var user userController.UserController
	var login userController.LoginAbout
	var check userController.CheckAbout
	userRouter := r.Group("/user", middleware.JWTAuthPlus())
	{
		userRouter.GET("/", user.QueryUsers)
		userRouter.GET("/:id", user.QueryUserById)
		userRouter.POST("/", user.AddUser)
		userRouter.PUT("/", user.UpdateUser)
		userRouter.DELETE("/", user.DeleteUser)
		userRouter.GET("/subset", user.QueryUserSubset)

		userRouter.GET("/withrole", userRoleController.UserRoleController{}.QueryUserRole)
	}
	loginRouter := r.Group("/")
	{
		loginRouter.GET("/imageCode", login.CreateImageCode)
		loginRouter.POST("/login", login.Login)
		loginRouter.POST("/register", login.Register)
	}
	checkRouter := r.Group("/check", middleware.JWTAuthPlus())
	{
		checkRouter.GET("/account", check.CheckAccount)
	}
}
